const path = require('path')

const resolve = dir => {
	return path.join(__dirname, dir)
}
const BASE_URL = 'https://app.shou-kuanbao.com'

module.exports = {
	configureWebpack: {
		name: '',
		resolve: {
			alias: {
				"@": resolve("./"),
				"_c": resolve("./common"),
				"_v": resolve("./pages"),
				"_a": resolve("./api")
			},
		},
	},
	// chainWebpack: config => {
	// 	config.resolve.alias
	// 		.set('@', resolve('src')) // key,value自行定义，比如.set('@@', resolve('src/common'))
	// 		.set('_c', resolve('src/static'))
	// 		.set('_v', resolve('src/views'))
	// 		.set('_a', resolve('src/api'))
	// },
	productionSourceMap: false,
	// 这里写你调用接口的基础路径，来解决跨域，如果设置了推手，那你本地开发环境的axios的baseUrl要写为 '' ，即空字符串
	// 配置转发推手
	devServer: {
		historyApiFallback: true,
		disableHostCheck: true,
		port: 8082,
		hot: true, //模块热替换
		hotOnly: false, //只有热更新不会刷新页面
		proxy: {
			[process.env.VUE_APP_BASE_API]: {
				target: BASE_URL,
				changeOrigin: true,
				pathRewrite: {
					['^' + process.env.VUE_APP_BASE_API]: process.env.VUE_APP_BASE_API
					// ['^' + process.env.VUE_APP_BASE_API]: '/'  
				}

			}
		}
	}
}
